package 选择排序;

import java.util.Arrays;

public class SelectSort {
    public static int[] selectSort(int[] arr){
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            int min = i;
            for (int j = i+1;j<n;j++){
                if (arr[min]>arr[j]){
                    min = j;
                }
            }
            int temp = arr[i];
            arr[i] = arr[min];
            arr[min] = temp;
        }
        return arr;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(selectSort(new int[]{1, 2, 45, 78, 63, 12, 48, 3, 87, 2})));

    }
}
